package com.k.spring.boot.data.hbase.controller;


import com.k.spring.boot.data.hbase.service.HbaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Controller
public class HbaseController {
    @Autowired
    private HbaseService service;

    @GetMapping("/createTable")
    @ResponseBody
    public Map<String, String> createTable(String tableName) throws IOException {
        Map<String, String> map = new HashMap<>();
        service.createTable(tableName, tableName);
        return map;
    }

    @GetMapping("/getData")
    @ResponseBody
    public Map<String, String> getData(String tableName) throws IOException {
        Map<String, String> map = new HashMap<>();
        service.getData(tableName);
        return map;
    }

    @GetMapping("/putData")
    @ResponseBody
    public Map<String, String> putData(String name, String colFamily, String rowKey, Map<String, String> data) throws IOException {
        Map<String, String> map = new HashMap<>();
        service.putData(name, colFamily, rowKey, data);
        return map;
    }


}
